package com.jp.java8;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

public class CreateStream {
    public static void main(String[] args) throws IOException {

        List<String> list = Arrays.asList("A","B","C");
        list.stream();

        Stream.of("A","B","C");

        String[] strings = {"A","B","C"};
        Arrays.stream(strings);

//        Path path = Paths.get("/a/b/c");
//        try (Stream<String> lines = Files.lines(path)){
//
//        }

        Stream<Integer> stream = Stream.iterate(0,n->n+2);

        Stream<Double> stream1 = Stream.generate(Math::random);

        String[] strings1= {"Abc","Bcd","Cda"};
        Stream<String[]> stream2 = Arrays.stream(strings1).map(s -> s.split(""));
        Stream<String> stream3 = stream2.flatMap(Arrays::stream);
        stream3.distinct().forEach(System.out::println);

        List<Integer> list1 = Arrays.asList(1,2,3);
        Stream<Integer> stream4 = list1.stream();
        Integer result = stream4.reduce(0,(i,j)->i+j);
        System.out.println(result);

        Stream<Integer> stream5 = list1.stream();
        stream5.reduce((i,j)->i>j?i:j).ifPresent(System.out::println);

    }
}
